using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication1.Models.Mapping
{
    public class LaptopMap : EntityTypeConfiguration<Laptop>
    {
        public LaptopMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Brand)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Description)
                .IsRequired();

            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.Configuration_CPU)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Configuration_Memory)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Configuration_Board)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Configuration_HardDisk)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Configuration_VideoAdapter)
                .IsRequired()
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("Laptops");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Brand).HasColumnName("Brand");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.ImageUrl).HasColumnName("ImageUrl");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Configuration_CPU).HasColumnName("Configuration_CPU");
            this.Property(t => t.Configuration_Memory).HasColumnName("Configuration_Memory");
            this.Property(t => t.Configuration_Board).HasColumnName("Configuration_Board");
            this.Property(t => t.Configuration_HardDisk).HasColumnName("Configuration_HardDisk");
            this.Property(t => t.Configuration_VideoAdapter).HasColumnName("Configuration_VideoAdapter");
            this.Property(t => t.UnitPrice).HasColumnName("UnitPrice");
        }
    }
}
